Skip to content

Conversation

admin-coderabbit
Copy link
Owner

@admin-coderabbit admin-coderabbit commented Feb 4, 2026

This pull request was automatically created by @coderabbitai/e2e-reviewer.

Batch created pull request.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced Rolling Updates as a preview feature for Keycloak updates
  • Documentation

    • Added requirements to enable rolling-updates feature for operator-based updates
    • Updated update-compatibility documentation with feature enablement prerequisites
    • Enhanced exit codes for update-compatibility checks to reflect rolling-updates status

Closes #36840

Signed-off-by: Pedro Ruivo <pruivo@redhat.com>
@coderabbit-eval
Copy link

coderabbit-eval bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The PR introduces a new "Rolling Updates" preview feature to Keycloak. It adds a ROLLING_UPDATES enum constant to the Feature class, implements feature-enabled checks in update-related CLI commands, updates documentation to document the feature requirement, and adjusts exit codes to distinguish feature-disabled states.

Changes

Cohort / File(s) Summary
Feature Definition
common/src/main/java/org/keycloak/common/Profile.java
Added new PREVIEW-type enum constant ROLLING_UPDATES to the Feature enum.
CLI Command Guards
quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/cli/command/UpdateCompatibilityCheck.java, quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/cli/command/UpdateCompatibilityMetadata.java
Added feature-flag checks that exit early with FEATURE_DISABLED status when rolling-updates is not enabled.
Command Support Utilities
quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/cli/command/AbstractUpdatesCommand.java
Added printFeatureDisabled() method to output feature-disabled error messages.
Exit Code Management
quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/compatibility/CompatibilityResult.java
Changed RECREATE_UPGRADE_EXIT_CODE from 4 to 3; added new FEATURE_DISABLED constant with value 4.
Documentation
docs/guides/operator/advanced-configuration.adoc, docs/guides/server/update-compatibility.adoc, docs/guides/templates/kc.adoc
Added CAUTION blocks and example configurations documenting the requirement to enable rolling-updates feature; updated command invocation examples.
Infrastructure Configuration
operator/scripts/Dockerfile-custom-image
Added --features=rolling-updates flag to kc.sh build command.
Operator Tests
operator/src/test/java/org/keycloak/operator/testsuite/integration/UpgradeTest.java
Replaced deprecated UnsupportedSpec usage with FeatureSpec initialization; enabled rolling-updates feature in test deployment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A feature hopping into view,
Rolling updates shiny and new!
Preview stage with guards in place,
Exit codes mark the feature's trace—
Swift hops forward, feature-aware,
Updates rolling through the air! 🌀

🚥 Pre-merge checks | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks substantive detail about what changes were made and why, relying instead on generic boilerplate text about automated creation. Add a meaningful description explaining the rolling-updates feature addition, CLI changes, documentation updates, and the rationale for these changes beyond stating it was auto-generated.
Title check ❓ Inconclusive The title 'Automated Test: feature-rolling-updates-implementation' is vague and uses generic phrasing that doesn't convey the actual changes made in the PR. Provide a clear, specific title that describes the main change, such as 'Add rolling-updates feature flag and CLI compatibility checks' or 'Implement rolling-updates preview feature with validation logic'.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-rolling-updates-implementation

Comment @coderabbit eval help to get the list of available commands and usage tips.

@coderabbit-eval coderabbit-eval bot closed this Feb 4, 2026
Copy link

@coderabbit-eval coderabbit-eval bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
operator/src/test/java/org/keycloak/operator/testsuite/integration/UpgradeTest.java (1)

102-116: ⚠️ Potential issue | 🟠 Major

Enable rolling-updates feature for all strategy paths, including when updateStrategy is null.

The test at line 94-95 expects rolling upgrade behavior when updateStrategy == null, but the ROLLING_UPDATES feature is only enabled for non-null strategies (lines 112-115). Move the feature setup before the early return to ensure it applies to all paths.

Suggested adjustment
 private static Keycloak createInitialDeployment(UpdateStrategy updateStrategy) {
     var kc = getTestKeycloakDeployment(true);
     kc.getSpec().setInstances(3);
+    if (kc.getSpec().getFeatureSpec() == null) {
+        kc.getSpec().setFeatureSpec(new FeatureSpec());
+    }
+    kc.getSpec().getFeatureSpec().setEnabledFeatures(List.of(Profile.Feature.ROLLING_UPDATES.getKey()));
+
     if (updateStrategy == null) {
         return kc;
     }
     var updateSpec = new UpdateSpec();
     updateSpec.setStrategy(updateStrategy);
     kc.getSpec().setUpdateSpec(updateSpec);
-
-    if (kc.getSpec().getFeatureSpec() == null) {
-        kc.getSpec().setFeatureSpec(new FeatureSpec());
-    }
-    kc.getSpec().getFeatureSpec().setEnabledFeatures(List.of(Profile.Feature.ROLLING_UPDATES.getKey()));
     return kc;
 }
🤖 Fix all issues with AI agents
In `@docs/guides/operator/advanced-configuration.adoc`:
- Around line 446-450: Reword the CAUTION block to fix grammar and clarify the
actual failure mode: state that while the rolling-updates feature is in preview,
attempting to run the update compatibility check commands (kc update check and
kc update metadata) will exit with a feature-disabled status; the {project_name}
Operator itself continues to operate normally. Replace "While on preview stage"
with "While the feature is in preview" (or "While in preview stage") and make
clear this limitation applies only to using the rolling-updates compatibility
checks, not general Operator functionality.

In `@docs/guides/server/update-compatibility.adoc`:
- Around line 132-134: Update the documentation text that currently maps exit
code 4 to "Rolling Upgrade is not possible" so it accurately reflects that the
command aborted because the preview feature is disabled; change the wording for
exit code 4 to something like "Command cannot run because the preview feature
`rolling-updates` is disabled" and ensure the doc line referencing exit code 4
(the entry showing "Rolling Upgrade is not possible" and mention of
`rolling-updates`) is replaced accordingly.

In
`@quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/compatibility/CompatibilityResult.java`:
- Around line 31-35: The change swapped semantics of exit codes so external
tooling expecting recreate-upgrade on code 4 will break; restore backward
compatibility by keeping RECREATE_UPGRADE_EXIT_CODE = 4 (or add a
LEGACY_RECREATE_UPGRADE_EXIT_CODE = 4) and assign FEATURE_DISABLED to a
different code (e.g., 5), or introduce both constants
(RECREATE_UPGRADE_EXIT_CODE = 4 and FEATURE_DISABLED = 5) and mark the old
mapping as deprecated; update the CompatibilityResult constants
(RECREATE_UPGRADE_EXIT_CODE, FEATURE_DISABLED or add
LEGACY_RECREATE_UPGRADE_EXIT_CODE) and add a short deprecation comment so
callers/tools can adapt.

Comment on lines +446 to +450
[CAUTION]
====
While on preview stage, the feature `rolling-updates` must be enabled.
Otherwise, the {project_name} Operator will fail.
====

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the file context around lines 446-450
head -n 480 docs/guides/operator/advanced-configuration.adoc | tail -n 50

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 1973


🏁 Script executed:

# Search for rolling-updates feature mentions in the codebase
rg "rolling-updates" --type adoc --type md --type java --type yaml -B 2 -A 2

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 115


🏁 Script executed:

# Look for operator failure behavior related to rolling-updates
rg "rolling.?update" -i --type java -B 3 -A 3 | head -100

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 12841


🏁 Script executed:

# Check if there's operator code that validates rolling-updates enablement
rg "rolling" --type java -l | head -20

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 1464


🏁 Script executed:

# Search for validation of rolling-updates feature
rg "rolling.?update" -i --type java -B 5 -A 5 | grep -E "(fail|error|throw|require|validate)" -B 3 -A 3

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 5057


🏁 Script executed:

# Search for feature validation logic
rg "features.*enabled" --type java -B 3 -A 3 | head -80

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 9971


🏁 Script executed:

# Look for upgrade logic that might require rolling-updates
rg "UpgradeType|ROLLING|RECREATE" --type java | grep -i "strategy\|feature" | head -20

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 1150


🏁 Script executed:

# Check BaseUpgradeLogic which likely has upgrade handling
cat -n operator/src/main/java/org/keycloak/operator/upgrade/impl/BaseUpgradeLogic.java | head -150

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 7218


🏁 Script executed:

# Find and read UpdateCompatibilityCheck.java
find . -name "UpdateCompatibilityCheck.java" -type f -exec cat -n {} \;

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 3976


🏁 Script executed:

# Find and read UpdateCompatibilityMetadata.java
find . -name "UpdateCompatibilityMetadata.java" -type f -exec cat -n {} \;

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 4631


🏁 Script executed:

# Search for any error or failure behavior when rolling-updates feature is absent
rg "ROLLING_UPDATES" --type java -B 5 -A 5

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 5394


Clarify the specific failure mode and fix grammar.

The CAUTION states the Operator "will fail" if rolling-updates is not enabled, but the actual behavior is more limited: the update compatibility check commands (kc update check and kc update metadata) exit with a feature-disabled status when the feature is disabled. The Operator itself continues to function; it does not prevent general operation. Consider: "While the feature is in preview stage" (or "While in preview stage") instead of "While on preview stage" for correct grammar. Reword to clarify that this constraint applies to using rolling update compatibility checks, not to the Operator as a whole.

🤖 Prompt for AI Agents
In `@docs/guides/operator/advanced-configuration.adoc` around lines 446 - 450,
Reword the CAUTION block to fix grammar and clarify the actual failure mode:
state that while the rolling-updates feature is in preview, attempting to run
the update compatibility check commands (kc update check and kc update metadata)
will exit with a feature-disabled status; the {project_name} Operator itself
continues to operate normally. Replace "While on preview stage" with "While the
feature is in preview" (or "While in preview stage") and make clear this
limitation applies only to using the rolling-updates compatibility checks, not
general Operator functionality.

Comment on lines +132 to +134
m|4
|Rolling Upgrade is not possible.
The feature `rolling-updates` is disabled.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Reword exit-code 4 to reflect “feature disabled.”

Exit code 4 is returned before any compatibility evaluation, so describing it as “Rolling Upgrade is not possible” is misleading. Suggest wording like “Command cannot run because the preview feature rolling-updates is disabled.”

✏️ Suggested doc tweak
-m|4
-|Rolling Upgrade is not possible.
-The feature `rolling-updates` is disabled.
+m|4
+|Command cannot run because the preview feature `rolling-updates` is disabled.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
m|4
|Rolling Upgrade is not possible.
The feature `rolling-updates` is disabled.
m|4
|Command cannot run because the preview feature `rolling-updates` is disabled.
🤖 Prompt for AI Agents
In `@docs/guides/server/update-compatibility.adoc` around lines 132 - 134, Update
the documentation text that currently maps exit code 4 to "Rolling Upgrade is
not possible" so it accurately reflects that the command aborted because the
preview feature is disabled; change the wording for exit code 4 to something
like "Command cannot run because the preview feature `rolling-updates` is
disabled" and ensure the doc line referencing exit code 4 (the entry showing
"Rolling Upgrade is not possible" and mention of `rolling-updates`) is replaced
accordingly.

Comment on lines +31 to +35
// see picocli.CommandLine.ExitCode
// 1 -> software error
// 2 -> usage error
int RECREATE_UPGRADE_EXIT_CODE = 3;
int FEATURE_DISABLED = 4;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Search for references to RECREATE_UPGRADE_EXIT_CODE and exit code values
rg -n "RECREATE_UPGRADE_EXIT_CODE|FEATURE_DISABLED" --type java

# Check for test files that might reference exit codes
rg -n "exitCode|exit.*4|exit.*3" --type java -A 2 -B 2 | head -100

# Search for documentation files mentioning exit codes
fd -e adoc -e md | xargs grep -l "exit.code\|exitCode" 2>/dev/null || true

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 15287


🏁 Script executed:

# More focused search: find where these constants are used
rg -n "return RECREATE_UPGRADE_EXIT_CODE|return.*4|System.exit" --type java -A 2 -B 2

# Check the IncompatibilityResult class mentioned in original scratchpad
fd -n "IncompatibilityResult.java" --type f

Repository: admin-coderabbit/coderabbit-keycloak-mirror

Length of output: 50648


Breaking change: Exit code 4 now has different semantics.

Previously, exit code 4 indicated that a recreate upgrade was required. After this change, exit code 4 now indicates that a feature is disabled, while exit code 3 indicates recreate upgrade is required. Any external scripts or automation tools checking for exit code 4 to detect the need for a recreate upgrade scenario will break and require updates.

🤖 Prompt for AI Agents
In
`@quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/compatibility/CompatibilityResult.java`
around lines 31 - 35, The change swapped semantics of exit codes so external
tooling expecting recreate-upgrade on code 4 will break; restore backward
compatibility by keeping RECREATE_UPGRADE_EXIT_CODE = 4 (or add a
LEGACY_RECREATE_UPGRADE_EXIT_CODE = 4) and assign FEATURE_DISABLED to a
different code (e.g., 5), or introduce both constants
(RECREATE_UPGRADE_EXIT_CODE = 4 and FEATURE_DISABLED = 5) and mark the old
mapping as deprecated; update the CompatibilityResult constants
(RECREATE_UPGRADE_EXIT_CODE, FEATURE_DISABLED or add
LEGACY_RECREATE_UPGRADE_EXIT_CODE) and add a short deprecation comment so
callers/tools can adapt.

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant